package war2100.editor;

import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JPanel;

import war2100.entity.tiles.Tile;

public class TileChoiceButton extends JPanel implements MouseListener {
	private static final long serialVersionUID = -7592573069714926351L;

	private TileChoice tileChoice;
	private Tile value;

	public TileChoiceButton(TileChoice tileChoice, Tile value) {
		this.tileChoice = tileChoice;
		this.setValue(value);
		this.setSize(140, 140);
		this.addMouseListener(this);
	}

	public Tile getValue() {
		return value;
	}

	public void setValue(Tile value) {
		this.value = value;
	}

	@Override
	public void mouseClicked(MouseEvent e) {
	}

	@Override
	public void mouseEntered(MouseEvent e) {
	}

	@Override
	public void mouseExited(MouseEvent e) {
	}

	@Override
	public void mousePressed(MouseEvent e) {
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		tileChoice.setCurrentTile(value);
	}

        @Override
	public void paint(Graphics g) {
		super.paint(g);

		int width = this.getWidth() - 10;
		int height = this.getHeight() - 5;
		value.render(g, 5, 5, width, height);
	}
}
